package com.shass.mybatis.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.shass.mybatis.service.UserService;

@RestController
@RequestMapping("/user") 
@Api(tags="查询用户信息接口")
public class UserController {

	@Autowired
	private UserService service ;
	
	@ApiOperation(value = "根据用户名获取用户信息", response = String.class,notes = "根据用户名获取用户信息")
	@GetMapping("/getUserByName/{username}")
	public Map<String, Object> getUser(@PathVariable("username") String username){
		return service.getUserByName(username) ;
	}
	
	@ApiOperation(value = "获得hello字符串", response = String.class,notes = "根据传参或者hello加参数")
	@GetMapping("/hello/{name}")
	public String say(@PathVariable("name")String name){
		return "hello "+name ;
	}
	
	@GetMapping("/getUserByValue")
	public List<?> getUserByValue(String username,String fullname){
		return service.getUserByValue(username, fullname) ;
	}
	
	@GetMapping("/getUserByMap")
	public List<?> getUserByMap(String username,String fullname){
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("username", username) ;
		map.put("fullname", fullname) ;
		return service.getUserByMap(map) ;
	}
}
